package kib.fun.server.gui;

import java.net.NetworkInterface;
import java.util.Enumeration;

public class IpErmittler {

	public static void main(String[] args) {
		
	}
	
	public static String getIpAdresse(){
		try {
			Enumeration networkInterfaces = NetworkInterface
					.getNetworkInterfaces();
			while (networkInterfaces.hasMoreElements()) {
				NetworkInterface networkInterface = (NetworkInterface) networkInterfaces
						.nextElement();
				if (networkInterface.isUp()
						&& !networkInterface.isVirtual()
						&& networkInterface.getInetAddresses()
								.hasMoreElements()
						&& !networkInterface.isLoopback()) {
					if(networkInterface.getName().equals("net4")){
						String ipAdresse = String.format("%s",networkInterface.getInetAddresses()
								.nextElement());
						return ipAdresse;
					}

				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}

}
